function z = findLam(lam)
global css c c0 betta sigma depr taumax r T

c1ss=lam*css;
c1=lam*c;
c10=lam*c0;

Ddenom=sum(betta.^[0:T-1].*(c1.^(-sigma).*c1)) + betta^T/(1-betta)*(c1ss^(-sigma)*c1ss); %from (7)

z=(1-1/lam)*Ddenom+c10^(-sigma)*(1+r(1)*(1-taumax)-depr);
